package com.dzk.cp.test;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import net.sf.json.JSONArray;
import net.sf.json.JsonConfig;
import net.sf.json.util.PropertyFilter;

import com.dzk.cp.c11x5.util.C11x5Utils;
import com.dzk.cp.c11x5.vo.C11x5CodeJsonVO;
import com.dzk.cp.util.CpUtils;

public class Main {

	public static void main(String[] args) {
//		List<Integer> list = Arrays.asList(new Integer[] {
//				1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 
//				12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 
//				23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33
//		});
//		List<List<Integer>> resultList = CpUtils.combine(list, 6);
//		System.out.println(resultList);
//		
//		Integer[] ints = new Integer[] {1,};
//		System.out.println(ints.length);
//		
//		List<List<Integer>> resultList = CpUtils.permute(list, 3);
//		System.out.println("size=" + resultList.size());
//		System.out.println(resultList);
//		
//		print_Q3Attr();
//		print_R5Attr();
		
//		LinkedList<Integer> list = new LinkedList<Integer>(Arrays.asList(new Integer[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}));
//		int n1, n2, n3;
//		Random r = new Random();
//		for (int i = 0; i < 30000; i++) {
//			int j = 0;
//			int m = 0;
//			while (true) {
//				j++;
//				n1 = list.remove(r.nextInt(list.size()));
//				n2 = list.remove(r.nextInt(list.size()));
//				n3 = list.remove(r.nextInt(list.size()));
//				list.add(n1);
//				list.add(n2);
//				list.add(n3);
//				if (n1 == 3 && n2 == 1 && n3 == 11) {
//					m = j;
//					break;
//				}
//			}
//			if (m >= 10000) {
//				System.out.println(m);
//			}
//		}
		
		int n = 6+24+24+24+36+48+24+48+36+24+36+48+36+24+48+48+48+48+24+48+36+48+48+48+36+48+24;
		System.out.println(n);
		
		String json = "[{\"issue\":\"2013102205\",\"code\":\"02 01 08 07 11\",\"dx\":\"0:0\",\"jo\":\"0:0\"},{\"issue\":\"2013102206\",\"code\":\"07 11 01 06 08\",\"dx\":\"0:0\",\"jo\":\"0:0\"},{\"issue\":\"2013102207\",\"code\":\"06 10 08 09 05\",\"dx\":\"0:0\",\"jo\":\"0:0\"}]";
		JsonConfig jsonConfig = new JsonConfig();
		jsonConfig.setJsonPropertyFilter(new PropertyFilter() {
			@Override
			public boolean apply(Object o, String n, Object v) {
				return !n.equals("code") && !n.equals("issue");
			}
		});
		JSONArray jsonArray = JSONArray.fromObject(json, jsonConfig);
		C11x5CodeJsonVO[] codeJsonVOs = (C11x5CodeJsonVO[]) JSONArray.toArray(jsonArray, C11x5CodeJsonVO.class);
		System.out.println(codeJsonVOs);
	}
	
	public static void print_Q3Attr() {
		List<Integer> list = Arrays.asList(new Integer[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11});
		List<List<Integer>> resultList = CpUtils.permute(list, 3);
		System.out.println("id|n1|n2|n3|ns|js|os|ds|xs|y0|y1|y2|hz|kd");
		for (int i = 0; i < resultList.size(); i++) {
			List<Integer> elemList = resultList.get(i);
			System.out.print(i + 1);
			System.out.print("|");
			System.out.print(elemList.get(0));
			System.out.print("|");
			System.out.print(elemList.get(1));
			System.out.print("|");
			System.out.print(elemList.get(2));
			System.out.print("|");
			Collections.sort(elemList);
			for (int j = 0; j < elemList.size(); j++) {
				System.out.print(CpUtils.fore2zero(elemList.get(j)));
				if (j != elemList.size() - 1) {
					System.out.print(" ");
				}
			}
			System.out.print("|");
			System.out.print(C11x5Utils.getOddNum(elemList));
			System.out.print("|");
			System.out.print(C11x5Utils.getEvenNum(elemList));
			System.out.print("|");
			System.out.print(C11x5Utils.getBigNum(elemList));
			System.out.print("|");
			System.out.print(C11x5Utils.getSmallNum(elemList));
			System.out.print("|");
			System.out.print(C11x5Utils.getY0Num(elemList));
			System.out.print("|");
			System.out.print(C11x5Utils.getY1Num(elemList));
			System.out.print("|");
			System.out.print(C11x5Utils.getY2Num(elemList));
			System.out.print("|");
			System.out.print(C11x5Utils.getSum(elemList));
			System.out.print("|");
			System.out.print(C11x5Utils.getKd(elemList));
			System.out.println();
		}
	}
	
	public static void print_R5Attr() {
		List<Integer> list = Arrays.asList(new Integer[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11});
		List<List<Integer>> resultList = CpUtils.combine(list, 5);
		System.out.println("id|ns|js|os|ds|xs|y0|y1|y2|hz|kd|lx");
		for (int i = 0; i < resultList.size(); i++) {
			List<Integer> elemList = resultList.get(i);
			System.out.print(i + 1);
			System.out.print("|");
			for (int j = 0; j < elemList.size(); j++) {
				System.out.print(CpUtils.fore2zero(elemList.get(j)));
				if (j != elemList.size() - 1) {
					System.out.print(" ");
				}
			}
			System.out.print("|");
			System.out.print(C11x5Utils.getOddNum(elemList));
			System.out.print("|");
			System.out.print(C11x5Utils.getEvenNum(elemList));
			System.out.print("|");
			System.out.print(C11x5Utils.getBigNum(elemList));
			System.out.print("|");
			System.out.print(C11x5Utils.getSmallNum(elemList));
			System.out.print("|");
			System.out.print(C11x5Utils.getY0Num(elemList));
			System.out.print("|");
			System.out.print(C11x5Utils.getY1Num(elemList));
			System.out.print("|");
			System.out.print(C11x5Utils.getY2Num(elemList));
			System.out.print("|");
			System.out.print(C11x5Utils.getSum(elemList));
			System.out.print("|");
			System.out.print(C11x5Utils.getKd(elemList));
			System.out.print("|");
			System.out.print(C11x5Utils.getLX(elemList));
			System.out.println();
		}
	}
	
}
